function getPublicIP() {
    const os = require("os");
    const faces = os.networkInterfaces();
    let en0 = "0.0.0.0";

    Object.keys(faces).forEach((name) => {
        let alias = 0;
        // @ts-ignore
        faces[name].forEach(function (iface) {
            if ("IPv4" !== iface.family || iface.internal !== false) {
                return;
            }
            if (alias >= 1) {
                en0 = iface.address;
            } else {
                en0 = iface.address;
            }
            ++alias;
        });
    });
    return en0;
}

module.exports = getPublicIP;
